package com.rush.paylog.db;

import java.io.File;

import android.content.Context;
import android.os.Environment;
import android.util.Log;

import com.ab.db.orm.AbSDDBHelper;
import com.rush.paylog.model.ChatMsg;
import com.rush.paylog.model.LocalUser;
import com.rush.paylog.model.Outlay;
import com.rush.paylog.model.PayType;
import com.rush.paylog.model.Stock;
import com.rush.paylog.model.User;


public class DBSDHelper extends AbSDDBHelper {
	// 数据库名
	private static final String DBNAME = "paylog4.db";
	// 数据库 存放路径
    private static final String DBPATH = "paylogdb";
    
    // 当前数据库的版本
	private static final int DBVERSION = 1;//,Outlay.class,PayType.class
	// 要初始化的表
	private static final Class<?>[] clazz = { User.class,Outlay.class,PayType.class};

	public DBSDHelper(Context context) {
		super(context,DBPATH, DBNAME, null, DBVERSION, clazz);
	}
	
	public void tests() {
		this.getReadableDatabase();
	}
	
	public static String getSdcardPath()
	{
		if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){ 
			File path =Environment.getExternalStorageDirectory();
			String p = path.getPath();
			if(!p.endsWith("/")){
				p = p+"/";
			}
			return p;
		}
		return "/sdcard/";
	}
	
	public static String  getDbPath() {
		String path=getSdcardPath()+DBPATH;
		
		
		
		try {
			File file=new File(path);
			
			if (!file.exists()) {
				file.mkdirs();
			} 
			
		} catch (Exception e) {
			// TODO: handle exception
		}
		Log.v("ou", "#############>>"+path);
		return path;
		
	}

}



